# Python函数可变参数（*args，**kwargs）详解
## 可变参数：形参前添加一个'*'
# 定义了支持参数收集的函数
from builtins import str
def dis_str(home, *str):
    print(home)
    # 输出str元组中的元素
    print("str =", str)
    for s in str:
        print(s)

# 可传入任何多个参数
dis_str("http://c.biancheng.net", "http://c.biancheng.net/python/", "http://c.biancheng.net/shell/")

def dis_str(*str, home):
    print(home)
    # 输出str元组中的元素
    print("str =", str)
    for s in str:
        print(s)
print()

dis_str("http://c.biancheng.net", "http://c.biancheng.net/python/", home = "http://c.biancheng.net/shell/")
# 下面的代码会出错
#dis_str("http://c.biancheng.net", "http://c.biancheng.net/python/", "http://c.biancheng.net/shell/")
# TypeError: dis_str() missing 1 required keyword-only argument: 'home'
print()

## 可变参数：形参前添加两个'*'
def dis_str(home, *str, **course):
    print(home)
    print(str)
    print(course)

# 调用函数
dis_str("C语言中文网", "http://c.biancheng.net", "http://c.biancheng.net/python/", shell教程 = "http://c.biancheng.net/shell/",
        go教程 = "http://c.biancheng.net/golang/", java教程 = "http://c.baincheng.net/java/")
print()

dis_str("C语言中文网")    
    
    